<template>
	<div class="topBlock">
		<div class="tabListBox">
			<div class="items" v-for="(item,index) in tabList" :key="index" @click="tabClick(item,index)">
				<img :class="{imgActive:activeIndex==index}" :src="activeIndex==index?item.imgActive:item.img" alt="">
				<span :class="{active:activeIndex==index}">{{item.title}}</span>
			</div>
		</div>
	</div>
</template>

<script>
	export default{
		props:{
			companyId:{
				type:String,
			},
			flag: {
				type:Number,
				default: 0 // 0不是上市企业, 1是上市企业
			}
		},
		data(){
			return {
				activeIndex:this.$route.query.tabIndex||0,
				tabList:[
					{
						img:require('../assets/images/qytab1.png'),
						imgActive:require('../assets/images/qytab1-active.png'),
						title:'重点企业画像',
						path:'/enterprise/tabswich?tabIndex=0&companyId='+this.companyId
					},
					{
						img:require('../assets/images/qytab2.png'),
						imgActive:require('../assets/images/qytab2-active.png'),
						title:'重点企业信用评估',
						path:'/enterprise/tabswich/creditEvaluation?tabIndex=1&companyId='+this.companyId
					},
					{
						img:require('../assets/images/qytab3.png'),
						imgActive:require('../assets/images/qytab3-active.png'),
						title:'重点企业商业谱系',
						path:'/enterprise/tabswich/businessPedigree?tabIndex=2&companyId='+this.companyId
					},
					/*
					{
						img:require('../assets/images/qytab4.png'),
						imgActive:require('../assets/images/qytab4-active.png'),
						title:'重点企业专题分析',
						path:'/enterprise/tabswich/thematicAnalysis?tabIndex=3&companyId='+this.companyId
					},*/
					{
						img:require('../assets/images/qytab4.png'),
						imgActive:require('../assets/images/qytab4-active.png'),
						title:'企业业务往来分析',
						path:'/enterprise/tabswich/corporateDealings?tabIndex=3&companyId='+this.companyId
					}
        ],
			}
		},
		created() {
      // console.log(typeof this.$route.query.flag)
      // 只有重庆长安汽车股份有限公司保留企业业务往来分析，其他的企业不显示
      this.getTabList()
			if(sessionStorage.getItem("companyName") !== '重庆长安汽车股份有限公司') {
				this.tabList = []
				this.tabList = [
					{
						img:require('../assets/images/qytab1.png'),
						imgActive:require('../assets/images/qytab1-active.png'),
						title:'重点企业画像',
						path:'/enterprise/tabswich?tabIndex=0&companyId='+this.companyId+'&flag=0'
					},
					{
						img:require('../assets/images/qytab2.png'),
						imgActive:require('../assets/images/qytab2-active.png'),
						title:'重点企业信用评估',
						path:'/enterprise/tabswich/creditEvaluation?tabIndex=1&companyId='+this.companyId+'&flag=0'
					},
					{
						img:require('../assets/images/qytab3.png'),
						imgActive:require('../assets/images/qytab3-active.png'),
						title:'重点企业商业谱系',
						path:'/enterprise/tabswich/businessPedigree?tabIndex=2&companyId='+this.companyId+'&flag=0'
					}
				]
			} else {
				this.tabList = []
				this.tabList = [
					{
						img:require('../assets/images/qytab1.png'),
						imgActive:require('../assets/images/qytab1-active.png'),
						title:'重点企业画像',
						path:'/enterprise/tabswich?tabIndex=0&companyId='+this.companyId
					},
					{
						img:require('../assets/images/qytab2.png'),
						imgActive:require('../assets/images/qytab2-active.png'),
						title:'重点企业信用评估',
						path:'/enterprise/tabswich/creditEvaluation?tabIndex=1&companyId='+this.companyId
					},
					{
						img:require('../assets/images/qytab3.png'),
						imgActive:require('../assets/images/qytab3-active.png'),
						title:'重点企业商业谱系',
						path:'/enterprise/tabswich/businessPedigree?tabIndex=2&companyId='+this.companyId
					},
					/*
					{
						img:require('../assets/images/qytab4.png'),
						imgActive:require('../assets/images/qytab4-active.png'),
						title:'重点企业专题分析',
						path:'/enterprise/tabswich/thematicAnalysis?tabIndex=3&companyId='+this.companyId
					},*/
					{
						img:require('../assets/images/qytab4.png'),
						imgActive:require('../assets/images/qytab4-active.png'),
						title:'企业业务往来分析',
						path:'/enterprise/tabswich/corporateDealings?tabIndex=3&companyId='+this.companyId
					}
				]
			}
		},
		methods:{
      getTabList(){
        if(sessionStorage.getItem('companyName') == '重庆长安汽车股份有限公司'){
          this.tabList = this.tabList.splice(-1,1)
        }
      },
			tabClick(item,index){
				this.$router.push({
					path:item.path
				})
				this.$emit('fun',index)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.topBlock{
		width:100%;
		height:auto;
		.tabListBox{
			width:100%;
			height:8vh;
			padding:0 20vw;
			box-sizing: border-box;
			display: flex;
			.items{
				flex: 1;
				cursor: pointer;
				transition: all .2s ease;
				img{
					width:3.5vw;
					// height:7.7vh;
					float: left;
					margin-right:.2vw;
					transition: all .2s ease;
				}
				.imgActive {
					margin-bottom: -2vh;
					width:5vw;
					// height:7.7vh;
					float: left;
					margin-right:.2vw;
					transition: all .2s ease;
				}
				span{
					color:rgba(231, 255, 252, 1);
					font-size: 0.98vw;
					line-height: 6.6vh;
					transition: all .2s ease;
				}
				span.active{
					color:rgba(0, 249, 252, 1);
					transition: all .2s ease;
				}
			}
		}
	}
</style>
